<template>
	<view class="canclelist">
		<view class="content" v-for="(item,index) in orderList" :key="index" @click="goShopDetail(item)">
			<view class="shops">
				<image class="shop_img" :src="item.goods_cover"></image>
				<view class="shops_right">
					<view class="name">{{item.goods_name}}</view>
					<view class="price_msg">
						已获取红包金额:￥{{item.package_total_price}}
					</view>
					<view class="create_time">
						<text>{{item.create_date}}</text>
						<text class="buy_type">{{status[item.status]}}</text>
					</view>
				</view>
			</view>
		</view>
		
		<view v-show="isLoadMore && orderList.length >0">
			<uni-load-more :status="loadStatus"></uni-load-more>
		</view>
		
		<view class="nodata" v-if="orderList.length == 0">
			<image class="empty_img" :src="IMGLink+'/my/empty.png'" mode="widthFix"></image>
			<view>没有你想要的内容</view>
		</view>
	</view>
</template>
_
<script>
	import {
		grouplist
	} from "@/api/my/my.js"
	export default {
		data() {
			return {
				IMGLink: this.IMGLink,
				orderList: [],
				status: { //0已支付保证金 1抽中商品 2已退还保证金
					"0": "已支付保证金",
					"1": "抽中商品",
					"2": "已退还保证金"
				},
				page: 1, //页码
				size: '10',
				loadStatus: 'loading', //加载样式：more-加载前样式，loading-加载中样式，nomore-没有数据样式
				isLoadMore: false, //是否加载中
				refresh: false, // 下拉刷新标示
			}
		},
		onLoad() {
			this.getDataList();
		},
		methods: {
			getDataList() {
				uni.showLoading({
					title: '加载中'
				});
				grouplist('personalGroupInfo', {
					page: this.page,
					page_size: this.size,
					status: this.status,
				}).then(res => {
					let datas = res.data.list;

					this.orderList = this.page == 1 ? datas : this.orderList.concat(datas);
					if (datas.length < this.size) { //小于size数，停止请求
						this.isLoadMore = true;
						this.loadStatus = 'nomore';
					} else {
						this.isLoadMore = false;
					}
					uni.hideLoading();

					if (this.refresh) {
						uni.stopPullDownRefresh();
						this.refresh = false;
					}
				}).catch(error => {
					uni.hideLoading();
					this.isLoadMore = false;
				})
			},
			onPullDownRefresh() {
				this.page = 1;
				this.getDataList();
				this.refresh = true;
			},
			onReachBottom() {
				if (!this.isLoadMore) { //此处判断，上锁，防止重复请求
					this.isLoadMore = true;
					this.page++;
					this.getDataList();
				}
			},
			goShopDetail(item){
				uni.navigateTo({
					url:`/pages/shopping/commodity/detail/index?id=${encodeURIComponent(item.goods_id)}&group_id=${item.id}&group_type=1`
				})
			}

		}
	}
</script>
<style>
	page {
		background-color: #EFF0F1;
	}
</style>
<style lang="scss" scoped>
	@import "../my.scss";

	.content {
		@include cards;
		background-color: #FFFFFF;
		margin: 20rpx 3%;
		font-size: 24rpx;
		color: #0A0C0D;
		padding: 40rpx 30rpx;

		.shops {
			@include flexLayout(center, space-between);

			.shop_img {
				width: 138rpx;
				height: 166rpx;
				border-radius: 12rpx;
			}

			&_right {
				width: 75%;
				height: 166rpx;
				@include flexLayout(flex-start, space-between);
				flex-direction: column;

				.name {
					@include exceedFlow(2);
				}

				.price_msg {
					width: 100%;
					color: #FF2A36;
					font-size: 24rpx;
					margin: 14rpx 0;
				}

				.create_time {
					width: 100%;
					@include flexLayout(center, space-between);
					color: #868686;

					.buy_type {
						color: #4C4C4C;
						font-size: 26rpx;
					}

				}
			}
		}
	}
	.nodata {
		text-align: center;
		color: #7D7D7D;
		font-size: 24rpx;
		margin-top: 50%;
	
		.empty_img {
			width: 468rpx;
		}
	}
</style>
